<template>
  <div class="update-gender">
    <van-picker
      show-toolbar
      title="修改性别"
      :columns="columns"
      :default-index="value"
      @cancel="$emit('close')"
      @confirm="onConfirm"
      @change="onPickerChange"
    />
  </div>
</template>

<script>
export default {
  name: 'UpdateGender',
  props: {
    value: {
      type: [Number],
      required: true
    }
  },
  data () {
    return {
      columns: ['女', '男'],
      localGender: this.value
    }
  },
  methods: {
    async onConfirm () {
      console.log(this.value)
      const localGender = this.localGender
      this.$emit('input', localGender)
      this.$emit('close')
    },
    onPickerChange (picker, value, index) {
      this.localGender = index
    }
  }
}
</script>

<style scoped lang="less"></style>
